<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link type="text/css" href="__PUBLIC__/css/jquery-weui.min.css" rel="stylesheet">
		<link type="text/css" href="__PUBLIC__/css/weui.min.css" rel="stylesheet" />
		<link type="text/css" href="__PUBLIC__/css/app.css" rel="stylesheet" />
		<title>推广注册</title>
	</head>
	<body style="background-image:url(__PUBLIC__/images/tui_sjcr_img.png);background-repeat:no-repeat;background-size: 100%;">
		<div class="tui_bg" style="margin-top:90%; background: none;  ">
			<!-- <img src="__PUBLIC__/images/tui_sjcr_img.png" style="width: 100%;">  style="background:#fc6637;" -->
			<!-- <section class="tui_span">
				<span>微投入轻创业</span>
				<span>个人专属贷款超市</span>
				<span>信贷中介必备</span> 
			</section> -->
			<form action="#" method="post" id="formf" style="margin-top: 113%;padding-left:20px;padding-right:20px;">
				<section class="input_block" style="border:1px solid #DBDBDB;">
					<input type="text" name="Mobile" id="Mobile" placeholder="请输入手机号" style="border-radius: 50%;width: 100%;height: 100%;"/>
				</section>

				<section class="input_block" style="border:1px solid #DBDBDB;">
					<input id="MsgCode" name="MsgCode" type="text" placeholder="请输入短信验证码" style="border-radius: 50%;width: 100%;height: 100%;">
					<a href="javascript:void(0);" id="getcode" onclick="getcode()" class="huo_yan" style="border-radius: 50%;background:white;color:#FD733D"> 获取验证码</a>
				</section>
				<input type="hidden" name="puser" id="puser" value="{$puser}">
			</form>
			<a class="input_block input_block1" style="width:60%;margin-left:20%;border-radius: 10px;font-weight: 400;font-size:18px;background:#F10093;letter-spacing:5px; " href="javascript:void(0);" onclick="fnRegister()">马上体现</a>

			<!-- <p class="center" style="color:white;">
				点击按钮则视为同意<a href="{:U('News/pages',array('ID'=>5))}" style="color:#f02f2d;">{$Title}</a>
			</p>  -->
			<!-- <p class="center" style="color:white;font-size:20px;padding-bottom:10px;">泰州市天铎网络科技有限公司</a>
			</p>  -->
		</div>

		<script src="__PUBLIC__/JS/jquery-2.1.4.js"></script>
		<script src="__PUBLIC__/JS/jquery-weui.min.js"></script>
		<!--<script src="__PUBLIC__/JS/common.js"></script>-->
	</body>
</html>
<script type="text/javascript">
	//该手机号码已注册,请点击确定跳转下载APP
	//恭喜您注册成功,请点击确定跳转下载APP
	//启用倒计时
	function times() {
		var setTime;
		var time = 60;
		setTime = setInterval(function() {
			if (time <= 0) {
				clearInterval(setTime);
				//添加事件
				$("#getcode").attr("onclick", "getcode()");
				$("#getcode").text('发送验证码');
				return;
			}
			time--;
			msgs = time + "s后重发";
			$("#getcode").text(msgs);
		}, 1000);
	}

	//获取验证码
	function getcode() {
		var mobile = $.trim($("#Mobile").val());
		// var code = $.trim($("#ImgCode").val());

		if (mobile == '') {
			alert("手机号码不能为空！");
			return false;
		}
		if (!mobile.match(/^((1[3-9][0-9]{1})+\d{8})$/)) {
			alert("手机号码格式不正确！");
			return false;
		}
// 		if (code == '') {
// 			$.alert("请输入图形验证码！");
// 			return false;
// 		}
		$.ajax({
			type: 'post',
			url: '{:U("index.php/Common/getcode")}',
			data: {
				mobile: mobile,
				check: 1
			},
			dataType: 'json',
			success: function(res) {
				if (res.result == 1) {
				    //弹出提示已注册，3秒后跳转至下载app页面
                    alert(res.message);
                    window.setTimeout(function(){
						window.location.href = "{$extension_url}";
					}, 2000);
				} else {
                    times();
                    alert(res.message);
				}
			}
		});
	}

	//注册
	function fnRegister() {
		var Mobile = $.trim($('#Mobile').val());
		// var Password = $.trim($("#Password").val());
		var MsgCode = $.trim($('#MsgCode').val());

		if (Mobile == '') {
			alert("请输入手机号码");
			return false;
		}
		if (!Mobile.match(/^((1[3-9][0-9]{1})+\d{8})$/)) {
			alert("手机号码格式不正确！");
			return false;
		}
		if (MsgCode == '') {
			alert("短信验证码不能为空！");
			return false;
		}
		// if (Password == '') {
		// 	$.alert("请输入您的密码，以英文字母开头，6-16位与数字的组合");
		// 	return false;
		// }
		// if (!Password.match(/^[a-zA-Z]\w{5,15}$/)) {
		// 	$.alert("密码必须是以英文字母开头，6-16位与数字的组合");
		// 	return false;
		// }

		$.ajax({
			type: "POST",
			url: "<?php echo U('index.php/Register/ajaxRegister');?>",
			data: $('#formf').serialize(),
			dataType: "json",
			success: function(data) {
				if (data.result == 1) {
                    //弹出提示已注册，3秒后跳转至下载app页面
                    alert(data.message);
                    window.setTimeout(function(){
                        window.location.href = "{$extension_url}";
                    }, 2000);
				} else {
					alert(data.message);
				}
			}
		});
	}
</script>
